﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.SessionState;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Common;

/// <summary>
/// 会员模块,页面基类
/// </summary>
public class MemberPageBase : System.Web.UI.Page
{
    public MemberPageBase()
    {
        //
        //TODO: 在此处添加构造函数逻辑
        //
    }

    #region 属性
    /// <summary>
    /// 用户登录名
    /// </summary>
    public string UserName
    {
        get
        {
            return this.User.Identity.Name;
        }
    }
    /// <summary>
    /// 用户 ID
    /// </summary>
    public string UserId
    {
        get
        {
            return UserInfo.UserId;
        }
    }
    /// <summary>
    /// 姓名
    /// </summary>
    public string FullName
    {
        get
        {
            return UserInfo.FullName;
        }
    }
    /// <summary>
    /// Email
    /// </summary>
    public string Email
    {
        get
        {
            return UserInfo.Email;
        }
    }
    /// <summary>
    /// 会员实体
    /// </summary>
    public Model.MembershipBase UserInfo
    {
        get
        {
            Model.MembershipBase _obj = BLL.MembershipBase.GetObjByUsername(UserName);
            return _obj;
        }
    }
    #endregion

    public void PageBegin()
    {
        if (string.IsNullOrEmpty(UserName))
        {
            Response.Redirect("http://" + RequestBase.GetCurrentFullHost() + ConfigurationManager.ConnectionStrings["ORG_UNIQUE_NAME"].ToString() + "/membership/signin.aspx");
            Response.End();
        }
    }

    /// <summary>
    /// 获取页面参数的值
    /// </summary>
    public string GetParaValue(string paraName)
    {
        string strValue = "";
        //如果Session中能够找到相应的参数值，则返回参数值
        try
        {
            HttpCookie authCookie = CookieEncrypt.GetCookie(FormsAuthentication.FormsCookieName);

            strValue = authCookie.ToString();
        }
        catch (Exception err)
        {
            err.ToString();
            strValue = "";
        }

        return strValue;
    }
}
